//注册vue-router
import Vue from 'vue'
import VueRouter from 'vue-router'
//1级路由
import Login from '../views/Login'
import Home from '../views/Home'
//二级路由
import Game from '../views/Home/Game'
import News from '../views/Home/News'
import Course from '../views/Home/Course'

import Item from '../views/Home/Course/Item.vue'


Vue.use(VueRouter)

const router = new VueRouter({
    routes:[
        {
            path:'/login',
            component:Login,
            name:'login'
        },
        {
            path:'/home',
            component:Home,
            name:'home',
            children:[
                {
                    path:'/home/game',
                    component:Game,
                    name:'game'
                },
                {
                    path:'course',
                    component:Course,
                    name:'course',
                    children:[
                        {
                            // path:'item/:id/:name',
                            path:'item/:id',
                            // path:'item',
                            // props:{a:1,b:2},
                            // props:true,
                            props:route=>({a:1,id:route.query.id,name:route.params.name}),
                            component:Item,
                            name:'item'
                        }
                    ]
                },
                {
                    path:'news',
                    component:News,
                    name:'news'
                },
                {
                    path:'',
                    redirect:'/home/course'
                }
            ]
        },
        {
            path:'/',
            redirect:'/home'
        }
    ]
})

export default router